<template>
  <div class="wrapper">
    <h3>Father</h3>
    <p>学校：{{name}}</p>
    <p>学校地址: {{address}}</p>
    <hr>

    <Son />

  </div>
</template>

<script>
import Son from './Son.vue'
export default {
  components: { Son },
  name: 'Father',
  data() {
    return {
      name: '',
      address: '',
    }
  },
  mounted(){
    console.log('Father this: ',this)
    // 绑定事件
    this.$bus.$on('get-school-name', (school)=>{
        this.name = school
    })
    this.$bus.$on('get-school-address', (address)=>{
        this.address = address
    })
  },
  beforeDestroy(){
    this.$bus.$off('get-school-name')
    this.$bus.$off('get-school-address')
  }
}
</script>

<style>
.wrapper {
  width: 500px;
  height: 300px;
  background-color: aquamarine;
}
</style>